<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>proxy</title>
</head>
<body>
    <script>
let targetObj = {
    name:'tom',
    age:23
}
let handler={//target有可能是map，key是被代理的变量，value是变量的值
    get(target, key){
        console.log('getting '+key);
        return target[key];
    },
    set(target, key, value){
        console.log('setting '+key);
        target[key] = value
    },
    apply(target, ctx, args){
        console.log('handle apply');
        return Reflect.apply(...arguments);
    }
}
let proxy = new Proxy(targetObj, handler)
proxy.name
proxy.age=25









    </script>
</body>
</html>